/*
 * Copyright (c) 2008 by 1eEurope (Switzerland) AG, Thalwil
 *
 * Customer:	1eEurope (Switzerland) AG
 * Project:		BKS
 * Created:		30.09.2008, WBL
 *
*/

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint;
using System.Xml.Xsl;
using System.IO;
using System.Xml;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web;
using Microsoft.SharePoint.Publishing.WebControls;

namespace By1eEurope.BKS.UserControlZone
{
    public class CQWPZoneControl : BaseFieldControl
    {
        public override object Value
        {
            get
            {
                this.EnsureChildControls();
                return "";
            }
            set
            {
                this.EnsureChildControls();
            }
        }

        protected override void CreateChildControls()
        {
            ContentByQueryWebPart cbq = new ContentByQueryWebPart();
            cbq.ListGuid = "f396e8db-492e-424a-915f-91b5e2f7c6f0";
            //cbq.MissingAssembly = "Dieses Webpart kann nicht importiert werden.";
            cbq.DataSourceID = "";
            cbq.Filter2ChainingOperator = ContentByQueryWebPart.FilterChainingOperator.Or;
            cbq.AllowMinimize = true;
            cbq.ZoneID = "ImportedPartZone";
            cbq.SortBy = "{8c06beca-0777-48f7-91c7-6da68bc07b69}";
            //cbq.ExportControlledProperties = true;
            cbq.WebUrl = "/";
            cbq.UseCopyUtil = true;
            cbq.Description = "Wird zum Anzeigen einer dynamischen Ansicht des Websiteinhalts auf einer Webseite verwendet";
            cbq.AllowHide = true;
            cbq.AllowConnect = true;
            cbq.Title = "Webpart fuer Inhaltsabfragen";
            cbq.ShowUntargetedItems = false;
            cbq.ViewContentTypeId = "";
            cbq.Filter1ChainingOperator = ContentByQueryWebPart.FilterChainingOperator.Or;
            cbq.GroupStyle = "DefaultHeader";
            //cbq.DetailLink = "";
            //cbq.PartImageSmall = "";
            //cbq.AllowRemove = true;
            cbq.PageSize = -1;
            //cbq.Dir = Microsoft.SharePoint.WebPartPages.Direction.Default;
            cbq.ConnectionID = new Guid("00000000-0000-0000-0000-000000000000");
            cbq.SortByFieldType = "DateTime";
            cbq.ServerTemplate = "100";
            //cbq.IsIncluded = true;
            cbq.UseSQLDataSourcePaging = true;
            cbq.ItemStyle = "Default";
            this.Controls.Add(cbq);
        }

        protected override void RenderFieldForDisplay(HtmlTextWriter output)
        {
        }

        protected override void Render(HtmlTextWriter output)
        {
            if (this.ControlMode == SPControlMode.Display)
                base.RenderChildren(output);

            base.Render(output);
        }
        
    }
}
